var e = require;
var t = module;
var n = exports;
var o,
    i =
        (this && this.__extends) ||
        ((o = function (e, t) {
            return (o =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
                })(e, t);
        }),
        function (e, t) {
            function n() {
                this.constructor = e;
            }
            o(e, t), (e.prototype = null === t ? Object.create(t) : ((n.prototype = t.prototype), new n()));
        }),
    r =
        (this && this.__decorate) ||
        function (e, t, n, o) {
            var i,
                r = arguments.length,
                a = r < 3 ? t : null === o ? (o = Object.getOwnPropertyDescriptor(t, n)) : o;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(e, t, n, o);
            else
                for (var s = e.length - 1; 0 <= s; s--)
                    (i = e[s]) && (a = (r < 3 ? i(a) : 3 < r ? i(t, n, a) : i(t, n)) || a);
            return 3 < r && a && Object.defineProperty(t, n, a), a;
        };
Object.defineProperty(n, "__esModule", {value: !0});
var a,
    l = e("events"),
    s = e("guide-manager"),
    c = e("target-item"),
    t = cc._decorator,
    e = t.ccclass,
    t = t.property,
    e =
        ((a = cc.Component),
        i(u, a),
        (u.prototype.start = function () {
            l.operEvent.on(this.onOperTap.bind(this));
        }),
        (u.prototype.onOperTap = function (e) {
            null != e &&
                null != e.action &&
                l.default.guideTarget == e.action &&
                s.GuideManager.ins.checkGuide(s.GuideStep.target, this.targetItems[4].getNextNode());
        }),
        (u.prototype.reseatItem = function () {
            this.arrow.active = !1;
            for (var e = 0; e < this.targetItems.length; e++) this.targetItems[e].reseat();
        }),
        (u.prototype.getTargetItemLength = function () {
            return this.targetItems.length;
        }),
        (u.prototype.setTargetNumbers = function (e) {
            for (var t = 0; t < this.targetItems.length; t++) this.targetItems[t].setLabel(e[t]);
        }),
        (u.prototype.setCurTargetNumber = function (n, o) {
            var e,
                i = this;
            0 == n || n >= this.targetItems.length
                ? (this.arrow.active = !1)
                : ((e = this.targetItems[n - 1].node.position),
                  this.arrow.setPosition(e.x + this.arrowDistance, e.y),
                  (this.arrow.active = o));
            for (
                var r, a, s, c = this, t = 0;
                t < this.targetItems.length &&
                "break" !==
                    (function (e) {
                        var t = c.targetItems[e];
                        if (e < n) {
                            if (e === n - 1 && n < c.targetItems.length)
                                return (
                                    (r = c.targetItems[n]),
                                    (a = r.getSpriteIdx(c.coinSpriteFrames.length)),
                                    o
                                        ? (t.setOver(o), r.setNext(o, c.coinSpriteFrames[a]))
                                        : t.setOver(o, function () {
                                              e != i.targetItems.length - 2 &&
                                                  l.operEvent.emit({
                                                      action: l.default.targetAnim,
                                                      data: {delayTime: 1}
                                                  }),
                                                  r.setNext(o, i.coinSpriteFrames[a], function () {
                                                      i.arrow.active = !0;
                                                  });
                                          }),
                                    "break"
                                );
                            t.setOver(o);
                        } else
                            e === n &&
                                ((s = t.getSpriteIdx(c.coinSpriteFrames.length)), t.setNext(o, c.coinSpriteFrames[s]));
                    })(t);
                t++
            );
        }),
        (u.prototype.lastTarget = function (e) {
            this.targetItems[this.targetItems.length - 1].setOver(!1, function () {
                e();
            });
        }),
        r([t(cc.Node)], u.prototype, "arrow", void 0),
        r([t(c.default)], u.prototype, "targetItems", void 0),
        r([t], u.prototype, "arrowDistance", void 0),
        r([t([cc.SpriteFrame])], u.prototype, "coinSpriteFrames", void 0),
        r([e], u));
function u() {
    var e = (null !== a && a.apply(this, arguments)) || this;
    return (e.arrow = null), (e.targetItems = []), (e.arrowDistance = 50), (e.coinSpriteFrames = []), e;
}
n.default = e;
